package com.ruoyi.business.enums.market;

import lombok.Getter;

import java.util.Arrays;
import java.util.Objects;

/**
 * 项目类型
 *
 * @author lcf
 */
public enum MarketTypeEnum {
    /**
     * 买
     */
    buy(1, "求购"),
    /**
     * 卖
     */
    sell(2, "售卖");

    @Getter
    private int code;
    @Getter
    private String name;

    MarketTypeEnum(int code, String name) {
        this.code = code;
        this.name = name;
    }

    public static MarketTypeEnum ofCode(Integer code) {
        return Arrays.stream(MarketTypeEnum.values()).filter(x -> Objects.equals(code, x.getCode())).findAny().orElse(null);
    }
}
